package com.zykj.hystrix.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @author zhoulj(周利军) [1217102780@qq.com]
 * @Title: DemoService
 * @Project: ${MODEL_NAME}
 * @Module ID:   <(模块)类编号，可以引用系统设计中的类编号>
 * @Comments: <对此类的描述，可以引用系统设计中的描述>
 * @JDK version used:      <JDK1.8> 54
 * @since 2018/12/22-0:54
 */
@Service
public class HystrixService {

    @Autowired
    RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "hystrixErr")
    public String getService(String name) {
        return restTemplate.getForObject("http://eureka-service-provider/demo?name=" + name, String.class);
    }

    public String hystrixErr(String name) {
        return "Hystrix 熔断器开始工作》》name:"+name;
    }


}
